<template>

  <el-tree

      :data="dictTreeData"
      :props="{label: 'dictName'}"
      ref="tree"
      default-expand-all
      node-key="dictCode"
  />
  
</template>
<script>
import baseCommonApi from "@/api/baseCommonApi";

export default {
  name: "startDictTree",
  computed: {},
  props: {
    dictCode: {
      type: String,
      required: true,
    }
  },
  data() {
    return {
      dictTreeData: [],
      treeKey: Math.random(),
    }
  },
  created() {
    this.init()
  },
  methods: {
    init() {
      this.dictTreeData = []
      baseCommonApi.loadDicDataByDictCode(this.dictCode).then(res => {
        this.dictTreeData = res.data.data || []
        this.treeKey = Math.random()
      })
    },
    nodeClick(data, node, nodeComp) {
      this.$emit("nodeClick", data, node, nodeComp);
    },
    clearCurrentNode() {
      this.$refs.tree.setCurrentKey(null);
    }

  }
}
</script>
<style scoped>

</style>
